package com.hc.server.actions;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.hc.server.Error;
import com.hc.server.IAction;
import com.hc.server.Request;
import com.hc.server.Response;

/**
 * 查询特产
 * @author xujh
 *
 */
public class QUERY_SPECIALTIES implements IAction {

	private static final String CITY = "CITY";
	private final static String KEY = "KEY";
	private final static String SORT = "SORT";
	private final static String PAGE_INDEX = "PAGE_INDEX";
	private final static String PAGE_SIZE = "PAGE_SIZE";
	
	private static final String NAME = "NAME";
	private final static String STOCK = "STOCK";//库存
	private final static String MPRICE = "MPRICE";
	private final static String SPRICE = "SPRICE";
	private static final String DES = "DES";
	
	private static final String SPECIALTIES = "SPECIALTIES";
	private static final String TOTAL_RESULT = "TOTAL_RESULT";
	
	@Override
	public void execute(Request req, Response resp) {
		int city;
		try {
			city = req.getIntArg(CITY);
		} catch (JSONException e) {
			resp.setErrResp(Error.INVALID_ARGS_ERR_CD, Error.INVALID_ARGS_ERR_MSG);
			return;
		}
		int orderBy = req.optIntArg(SORT);
		int pageIndex = req.optIntArg(PAGE_INDEX);
		int pageSize = req.optIntArg(PAGE_SIZE);
		
		JSONArray spes = new JSONArray();
		
		JSONObject spe = new JSONObject();
//		spe.put(NAME, value);
//		spe.put(SPRICE, value);
//		spe.put(MPRICE, value);
//		spe.put(STOCK, value);
//		spe.put(DES, value);
//		spe.put(KEY_WORD, value);
		spes.put(spe);
		
		resp.appendRespContent(SPECIALTIES, spes);
//		resp.appendRespContent(TOTAL_RESULT, value);
	}

}
